package com.woniuxy.controller;

import com.woniuxy.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: ideaAdmin
 * TODO: 接收前端发送的json数据
 * Date: 2022/1/25:16:02
 * Description:
 */
@RestController
@RequestMapping("/json")
public class ReceiveToJson {

    /**
     * @Author ideaAdmin
     * TODO:发送json数据
     * @Date 16:12 2022/1/25
     *  *
     * * @return java.util.Map<java.lang.String,java.lang.String>
     **/
    @RequestMapping("/toJson")
    @ResponseBody
    public Map<String,String> toJson(){
        Map<String, String> map = new HashMap<>();
        map.put("1","2");
        map.put("1","3");
        return map;
    }

    /**
     * @Author ideaAdmin
     * TODO:接收对象
     * @Date 16:13 2022/1/25
     * * @param student
     * * @return com.woniuxy.entity.Student
     **/
    @RequestMapping("/student")
    public String  toJson(@RequestBody Student student){
        return student.toString();
    }


}
